package android.framework.app.media;

import java.util.HashMap;

import android.app.ListActivity;
import android.content.Intent;
import android.framework.global.Constants;
import android.framework.media.PlayActivity;
import android.framework.media.octo.Stream;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Toast;

import android.framework.R;

public class HlsListHanyaActivity extends ListActivity {
	// 07-16 13:43:23.692: D/MediaPlayer(27432): java.io.FileNotFoundException:
	// No content provider:
	// http://hanyastar.vo.llnwd.net/o45/s/204/219/1343659/1343659_2013-03-23.m3u8

	public static final String LOGTAG = "OctoDemoPlayer";
	private final String[] urls = {
			"http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8",
			"http://hanyastar.vo.llnwd.net/o45/s/204/219/1433951/1433951_2013-05-15.m3u8",
			"http://hanyastar.vo.llnwd.net/o45/s/203/205/1435958/1435958_2013-05-17.m3u8",
			"http://hanyastar.vo.llnwd.net/o45/s/203/205/1435959/1435959_2013-05-17.m3u8",
			"http://hanyastar.vo.llnwd.net/o45/s/203/205/1435960/1435960_2013-05-17.m3u8",
			"http://hanyastar.vo.llnwd.net/o45/s/203/205/1435961/1435961_2013-05-17.m3u8",
			"http://hanyastar.vo.llnwd.net/o45/s/204/219/1343659/1343659_2013-03-23.m3u8" };
	private final String[] titles = { "GOOGLE_HLS", "电影刺夜", "浪淘沙第 1 集",
			"浪淘沙第 2  集", "浪淘沙第 3 集", "浪淘沙第  4 集", "电影在一起" };

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		ArrayAdapter<String> adp = new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, android.R.id.text1,
				titles);
		getListView().setAdapter(adp);
		getListView().setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {

				Intent intent = new Intent();
				intent.setClass(getApplicationContext(), PlayActivity.class);
				Bundle bundle = new Bundle();
				bundle.putString("url", urls[position]);
				bundle.putString("title", titles[position]);
				bundle.putBoolean(Constants.FROM_PUSH, false);
				bundle.putInt(Constants.PLAY_TYPE, Constants.PLAY_HLS);
				intent.putExtra(Constants.PLAY_PARM, bundle);
				startActivity(intent);
			}
		});
	}

}
